﻿<html>

	<head>
		<title>商品查询管理</title>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">

		<link href="../../css/skin/default/style.css" rel="stylesheet" type="text/css" />
		<link href="../../css/dialog.css" rel="stylesheet">
		<link href="../../js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />

		<script src="../../js/lib/jquery/jquery-1.10.2.min.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>

		<script src="../../js/lib/ligerUI/js/plugins/ligerPopupEdit.js"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerRadio.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerMenu.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
		<script src="../../js/lib/jquery.form.js" type="text/javascript"></script>
		<script src="../../js/lib/json2.js" type="text/javascript"></script>
		<script src="../../js/dialog.js"></script>
		<script src="../../js/JS/layout.js"></script>
		<script src="../../js/constants.js" type="text/javascript"></script>
		<script src="../../js/api.js" type="text/javascript"></script>

		<script type="text/javascript">
			var manager;
			$(document).hover(parent.hindMenu);

			var cmd = $api.getparastr("cmd");
			var ischild = $api.getparastr("ischild");
			var isMuit = $api.getparastr("isMuit");
			var key = $api.getparastr("key");
			var isCheck = false;

			var productUrl = BaseUrl + "Product?token=" + $api.getStorage("token");

			$(function() {
				$("form").ligerForm();
				initContorl();

				if(!$api.isEmpty(isMuit))
					isCheck = true;
				var url = productUrl;
				var sender = "";
				if(cmd == "cartad") {
					sender += "&status=1";
				} else
					sender += "&status=-1";
				sender += "&key=";
				sender += "&typeid=0";
				sender += "&bid=0";

				url += sender;
				manager = $("#maingrid4").ligerGrid({
					columns: [{
							display: '标题',
							name: 'title',
							align: 'left',
							wwidth: 320,
							render: function(rowdata, rowindex, value) {

								var ret = "<img src=" + rowdata.Fhimg + " class='listimgs' style='float:left;top:5px' />";
								ret += "<div style='margin-left:5px'><span  >" + "【" + rowdata.Fbrand + "】" + rowdata.Fsummary + "</span>";

								ret += "<div>"
								return ret;

							}
						},
						{
							display: '货号',
							name: 'Fpcode',
							align: 'left',
							width: 180,
							isSort: true
						},
						{
							display: '条码',
							name: 'Fbarcode',
							align: 'left',
							width: 180
						},
						{
							display: '原价',
							name: 'Foprice',
							isSort: true,
							width: 120,
							align: 'right'
						},
						{
							display: '售价',
							name: 'Fsaleprice',
							isSort: true,
							width: 120,
							align: 'left'
						},
						{
							display: '箱装数',
							name: 'Ft1',
							isSort: true,
							width: 120
						},
						{
							display: '大包装数',
							name: 'Ft2',
							isSort: true,
							width: 120
						}
					],
					dataAction: 'server',
					url: url,
					method: 'get',
					width: '99.5%',
					height: '350',
					rowHeight: 100,
					checkbox: isCheck,
					pageSize: 20,
					usePager: true //是否分页  

				});
			});

			var popPtype, popPSid;

			function initContorl() {
				popPtype = $("#PType").ligerPopupEdit({
					valueField: 'PID',
					textField: 'Name',
					width: 160,
					onEnterDown: function(e) {
						parent.showPTypeDialog(function(row) {
							popPtype.setValue(row.Fid);
							popPtype.setText(row.Fname);
							doSearch(true);
						});
					},
					onButtonClick: function() {
						parent.showPTypeDialog(function(row) {
							popPtype.setValue(row.Fid);
							popPtype.setText(row.Fname);
							doSearch(true);
						});
					}

				});
				var url = BaseUrl + "SysStore?token=" + $api.getStorage("token") + "&key=";
				$api.ajaxget(url, {}, function(result) {

					popPSid = $("#PSid").ligerComboBox({
						data: result.Rows,
						valueField: 'Fid',
						textField: 'Ftitle',
						onChangeValue: function(obj) {

							doSearch(true);
						}
					});

				});
			}

			function f_save() {
				var row = manager.getSelectedRow();
				if(row) {
					return row;
				}
				return null;

			}

			function showHSearch(isHHide) {
				if(isHHide) {
					$(".up").css("display", "block");
					$(".down").css("display", "none");
					$("#hsearch").css("display", "block");
					$("#searchword").text("收起");
				} else {
					$(".up").css("display", "none");
					$(".down").css("display", "block");
					$("#hsearch").css("display", "none");
					$("#searchword").text("高级查找");
				}
			}

			function getRows() {

				var rows = manager.getSelectedRows();
				if(rows) {
					return rows;
				}
				return null;
			}

			/*function doSearch(high) {
				var key = $("#txtKeywords").val();

				var sender = "";
				if(key.length !== 0 && '输入关键字搜索' != key) {
					sender += "&key=" + escape(key);
				}

				var url = "../../Api/product.ashx?Action=sql" + sender;
				manager.GetDataByURL(url);
			}*/

			function clear() {
				$("#txtKeywords").val("");
				popPtype.setText("");
				popPtype.setValue("");
				$("#PSid").val("");
			}

			function doSearch(high) {
				var key = $("#txtKeywords").val();
				if(high)
					key = $("#key").val();
				var sender = "&status=1&key=" + key;

				if(popPtype.getValue())
					sender += "&typeid=" + popPtype.getValue();
				else
					sender += "&typeid=0";
				//供应商
				if(popPSid.getValue())
					sender += "&sid=" + popPSid.getValue();
				else
					sender += "&sid=0";

				var url = productUrl + sender;

				manager.GetDataByURL(url);
			}
		</script>

	</head>

	<body class="mainbody2">
		<form id="form1" onsubmit="return false">
			<div class="toolbar-wrap">

				<div class="div-content">
					<dl>
						<dt style="width: 60px;">商品类别</dt>
						<dd style="margin-left: 70px;">
							<div style="margin-left: 10px;float:left;">
								<input id="PType" name="PType" placeholder='商品类别' ligerui="{width:180}" />
							</div>
						</dd>
						<dt style="width: 60px;">供应商</dt>
						<dd style="margin-left: 70px;">
							<div style="margin-left: 10px;float:left;">
								<input id="PSid" name="PSid" ligerui="{width:180}" />
							</div>
						</dd>
						<dt style="width: 60px;">关键词</dt>
						<dd style="margin-left: 70px;">
							<div style="margin-left: 10px;float:left;">
								<input type="text" placeholder='品名/货号/条码' ID="key" name="key" ltype="text" ligerui="{width:180,initSelect:true;nullText:'品名/货号/条码'}" />
							</div>
							<div style="float:left;margin-left: 10px;">
								<input style="display:inline" type="button" value="搜索" class="btn" onclick="doSearch();" />
							</div>
						</dd>
					</dl>
				</div>
			</div>

			<div id="maingrid4" style="margin: 0px;background:#fff;"></div>

		</form>

	</body>

</html>